﻿using System.Collections.Generic;

namespace Eneta.Portal.Common.Dto
{
    /// <summary>
    /// Class for forums.
    /// </summary>
    public class ForumDto : BaseDto 
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ForumDto"/> class.
        /// </summary>
        public ForumDto()
        {
            Moderators = new List<UserProfileDto>();
        }

        /// <summary>
        /// Gets or sets the category for forum.
        /// </summary>
        public ForumCategoryDto Category { get; internal set; }

        /// <summary>
        /// Gets or sets the description of forum.
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the last post posted to forum.
        /// </summary>
        public ForumPostDto LastPost { get; set; }

        /// <summary>
        /// Gets or sets the post count.
        /// </summary>
        public int PostCount { get; internal set; }

        /// <summary>
        /// Gets or sets the topic count.
        /// </summary>
        public int TopicCount { get; internal set; }

        /// <summary>
        /// Gets or sets the list of forum moderators.
        /// </summary>
        public IList<UserProfileDto> Moderators { get; private set; }

        /// <summary>
        /// Gets or sets the feed burner URL of forum.
        /// </summary>
        public string FeedBurnerUrl { get; set; }

        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
        /// </returns>
        public override int GetHashCode()
        {
            return Id;
        }

        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        /// 	<c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">
        /// The <paramref name="obj"/> parameter is null.
        /// </exception>
        public override bool Equals(object obj)
        {
            if(obj is ForumDto)
            {
                return (Id == ((ForumDto) obj).Id);
            }
            return false;
        }
    }
}
